//
//  toutiaoModel.m
//  WangI
//
//  Created by 刘珊珊 on 15/11/23.
//  Copyright (c) 2015年 刘珊珊. All rights reserved.
//

#import "HeadlineModel.h"


@implementation HeadlineModel

- (instancetype)initWithDataSource:(NSDictionary *)data
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:data];
        
    }
    return self;
}


-(id)valueForUndefinedKey:(NSString *)key {
    return nil;
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key {
    if ([key isEqualToString:@"ads"]) {
        NSArray *arr = value;
        NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:0];
        for (NSDictionary *dic in arr) {
            SecondModel *headline = [[SecondModel alloc] initWithDataSource:dic];
            [mutableArray addObject:headline];
        }
        self.dataSource = [NSArray arrayWithArray:mutableArray];
        
    }
    
    if ([key isEqualToString:@"imgextra"]) {
        NSArray *arr = value;
        NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:0];
        for (NSDictionary *dic in arr) {
            SecondModel *headline = [[SecondModel alloc] initWithDataSource:dic];
            [mutableArray addObject:headline];
        }
        self.dataSource1 = [NSArray arrayWithArray:mutableArray];
    }

  
}


@end
